Skip to main content

All Questions

0votes
1answer
57views

Cut-and-overlap reduction of N-dimensional array

Note: I have no idea what one might call this operation, so I've gone with "cut-and-overlap". Please let me know if there is an accepted terminology for something like this! Intro I need to ...
Heisenbugs's user avatar
0votes
1answer
55views

Writing to multidimensional arrays with variable dimension

I've initialized a list of arrays of different dimensions in Python and want to write to the entries of the arrays. If I want to write to the entry list[i, m1, m1, ..., m1, m2, m2, ..., m2] where m1 ...
serene's user avatar
-3votes
1answer
67views

Why can't I stack 3D arrays with np.concatenate in numpy, while 1D and 2D arrays work?

I'm working with 3D numpy arrays and having trouble stacking two of them. Here’s what I’m trying to do: import numpy as np grid = np.arange(16).reshape((1, 4, 4)) grid2 = grid[:, :-1, ::-1].copy() I ...
r0tten_appl3's user avatar
2votes
4answers
137views

Why the result is different? Numpy Slicing and indexing

Basically I want to obtain a part of the variable "cubote". I tried two methods that should work in the same way, but it didn't. My code: import numpy as np # Create a 3x3x3 cube ...
Hamilton Espitia's user avatar
2votes
3answers
264views

Python: Average Values in 2D-Array

I want to generate a twodimensional array in Python and I would like to iterate through each element and take an average. An element i should be averaged using the 8 surrounding array elements (...
s28's user avatar
  • 187
0votes
0answers
24views

Keep getting the error: "ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concatenation axis"

I've tried to implement a U-Net model to classify audio, and after preprocessing, I've converted the data into a dataset of float values. These are the shapes of my X and Y X_train shape: (3806, 2809) ...
Sunflower_Poet's user avatar
1vote
1answer
87views

How do I effectively compute pairwise quantities in numpy?

I want to compute pairwise quantities, e.g. distances between two points. A simple example would be import numpy as np N = 9 x = np.linspace(0,1,N) y = np.abs(x - x[:,None]) # pairwise 1d eucdlidian ...
knods's user avatar
0votes
0answers
72views

Interpolate y-value given x-value and data value in a 2D array

I am working with a 2D dataset with the x and y dimensions representing two separate variables, and the combined 2D grid representing a third variable. Here's a visual example of the dataset and the x ...
bashful_creature's user avatar
4votes
2answers
121views

Optimal multiplication of two 3D arrays having a variable dimension

I would like to multiply tensors R = {R_1, R_2, ..., R_M} and X = {X_1, X_2, ..., X_M} where R_i and X_i are 3×3 and 3×N_i matrices, respectively. How can I make maximum use of NumPy functionalities ...
TobiR's user avatar
0votes
1answer
520views

How to understand transpose operation on a 3D or Higher Dimensional Array

Consider a 3D array array_3d with shape (3, 2, 2): array_3d = np.array([ [[ 0, 1], [ 2, 3]], [[ 4, 5], [ 6, 7]], [[ 8, 9], [10, 11]] ]) array_3d.shape = (3, 2, 2) ...
Abdulla Saeed's user avatar
0votes
0answers
20views

error: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimensions [duplicate]

Getting the below error while executing the code for the ravdess dataset /usr/local/lib/python3.10/dist-packages/librosa/core/spectrum.py:266: UserWarning: n_fft=2048 is too large for input signal of ...
Yash489's user avatar
1vote
2answers
739views

ValueError: could not broadcast input array from shape A into shape B

I used Python with Numpy to create an array filled with numbers from a tuple, and set it up to be a 4x4 matrix. numbers = (-8, -3, -5, 0, 4, 5, 6, 10, 7,8, 9, 100, 10, 11, 12, 1000) numbers_array = ...
xgzvsx's user avatar
2votes
3answers
86views

Numpy slicing on a zero-padded 2D array

Given a 2D Numpy array, I'd like to be able to pad it on the left, right, top, bottom side, like the following pseudo-code. Is there anything like this already built into Numpy? import numpy as np a =...
Basj's user avatar
  • 46.7k
0votes
1answer
64views

NumPy ndarray non contiguous memory layout

I need some help in understanding the equations involved in finding the index of an element in an ndarray. I have been reading the Book "Guide to NumPy" by Travis A Oliphant. Link to the ...
user3851878's user avatar
0votes
1answer
42views

3d numpy array output, meant to emulate an image, can't convert to Image

I am creating an autostereogram with the function make_autostereogram. It is being output as a 3d NumPy array (rows, colums, RGB). It is then input into the Pillow function fromarray(). It has array ...
T. J. Foster's user avatar

153050per page
close